import Vue from "vue";
import VueRouter from "vue-router";
import Home from "../views/Home.vue";
import Login from "../views/login.vue"

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    name: "login",
    component: Login
  },

  {
    path: "/home",
    name: "home",
    component: Home,
    children: [
      {
        path: "/home/index",
        name: "index",
        component: () => import("../views/index.vue"),
      },
      {
        path: "/home/repair",
        name: "repair",
        children: [
          {
            path: "/home/repair/Messages",
            name: "Messages",
            component: () => import("../views/messgaes/Messages.vue")
          },
          {
            path: "/home/repair/change",
            name: "change",
            component: () => import("../views/change/Change.vue")
          },
          {
            path: "/home/repair/problem",
            name: "problem",
            component: () => import("../views/problems/Problem.vue")
          },
          {
            path: "/home/repair/Addproblem",
            name: "Addproblem",
            component: () => import("../views/problems/Addproblem.vue")
          },
          {
            path: "/home/repair/Handleproblem",
            name: "Handleproblem",
            component: () => import("../views/problems/Handleproblem.vue")
          },
          {
            path: "/home/repair/Persontotal",
            name: "Persontotal",
            component: () => import("../views/Persontotal.vue")
          },
          {
            path: "/home/repair/Zdpz",
            name: "Zdpz",
            component: () => import("../views/Zdpz/index.vue")
          },{
            path: "/home/repair/Gdmb",
            name: "Gdmb",
            component: () => import("../views/Gdmb.vue")
          },{
            path: "/home/repair/Lcpz",
            name: "Lcpz",
            component: () => import("../views/Lcpz.vue")
          },
        ],
        component: () => import("../views/Repair.vue"),
      },
      {
        path: "/home/knowledgebase",
        name: "knowledgebase",
        component: () => import('../views/index/KnowledgeBase.vue')
      },
      {
        path: "/home/notice",
        name: "notice",
        component: () => import('../views/index/Notice.vue')
      },
      {
        path: "/home/personal",
        name: "personal",
        component: () => import('../views/index/Personal.vue')
      },







      {
        path: "/home/knowledge",
        name: "knowledge",
        component: () => import("../views/knowledge.vue"),
        children: [
          {
            path: '/home/knowledge/wuJi10',
            name: 'wuJi10',
            component: () => import("../views/wuJiSS/whJi10.vue")
          },
          {
            path: '/home/knowledge/wuJi11',
            name: 'wuJi11',
            component: () => import('../views/wuJiSS/wuJi11.vue')
          },
          {
            path: '/home/knowledge/wuJiA',
            name: 'wuJiA',
            component: () => import('../views/wuJIS/wuJiA.vue')
          },
          {
            path: '/home/knowledge/wuJiB',
            name: 'wuJiB',
            component: () => import('../views/wuJIS/wuJiB.vue'),
            children: [
              {
                path: '/home/knowledge/wuJiB/wuJi1',
                name: 'wuJi1',
                component: () => import('../views/wuJiSS/wuJi1.vue'),
                children: [
                  {
                    path: '/home/knowledge/wuJiB/wuJi1/wuJi3',
                    name: 'wuJi3',
                    component: () => import('../views/wuJiSS/wuJi3.vue')
                  },
                  {
                    path: '/home/knowledge/wuJiB/wuJi1/wuJi4',
                    name: 'wuJi4',
                    component: () => import('../views/wuJiSS/wuJi4.vue')
                  },
                  {
                    path: '/home/knowledge/wuJiB/wuJi1/wuJi9',
                    name: 'wuJi9',
                    component: () => import('../views/wuJiSS/wuJi9.vue')
                  },
                ]
              },
              {
                path: '/home/knowledge/wuJiB/wuJi2',
                name: 'wuJi2',
                component: () => import('../views/wuJiSS/wuJi2.vue')
              },


            ]
          },
          {
            path: '/home/knowledge/wuJiC',
            name: 'wuJiC',
            component: () => import('../views/wuJIS/wuJiC.vue'),
            children: [
              {
                path: '/home/knowledge/wuJiC/wuJi5',
                name: 'wuJi5',
                component: () => import('../views/wuJiSS/wuJi5.vue'),
                children: [
                  {
                    path: '/home/knowledge/wuJiC/wuJi5/wuJi7',
                    name: 'wuJi7',
                    component: () => import('../views/wuJiSS/wuJi7.vue'),
                  },
                  {
                    path: '/home/knowledge/wuJiC/wuJi5/wuJi8',
                    name: 'wuJi8',
                    component: () => import('../views/wuJiSS/wuJi8.vue'),
                  },
                ]
              },
              {
                path: '/home/knowledge/wuJiC/wuJi6',
                name: 'wuJi6',
                component: () => import('../views/wuJiSS/wuJi6.vue')
              },
            ]
          },
          {
            path: '/home/knowledge/wuJiD',
            name: 'wuJiD',
            component: () => import('../views/wuJIS/wuJiD.vue')
          }, {
            path: '/home/knowledge/wuJiE',
            name: 'wuJiE',
            component: () => import('../views/wuJIS/wuJiE.vue')
          },
        ]
      },







      {
        path: "/home/settion",
        name: "settion",
        component: () => import("../views/settion.vue"),
        children: [
          {
            path: 'zuye',
            name: 'zuye',
            component: () => import('../views/xitong/zuye.vue')
          },
          {
            path: 'biaoge',
            name: 'biaoge',
            component: () => import('../views/xitong/biaoge.vue')
          },
          {
            path: 'bumen',
            name: 'bumen',
            component: () => import('../views/xitong/bumen.vue'),
            children: [

              {
                path:'sahnxi',
                name:'sahnxi',
                component: () => import('../views/xitong/sahnxi.vue')
              },
              {
                path:'hanzhong',
                name:'hanzhong',
                component: () => import('../views/xitong/hanzhong.vue')
              },
              {
                path:'xian',
                name:'xian',
                component: () => import('../views/xitong/xian.vue')
              },
              {
                path:'weinan',
                name:'weinan',
                component: () => import('../views/xitong/weinan.vue')
              },              {
                path:'hantai',
                name:'hantai',
                component: () => import('../views/xitong/hantai.vue')
              },
              {
                path:'nanzheng',
                name:'nanzheng',
                component: () => import('../views/xitong/nanzheng.vue')
              },
              {
                path:'beilin',
                name:'beilin',
                component: () => import('../views/xitong/beilin.vue')
              },
              {
                path:'dazhi',
                name:'dazhi',
                component: () => import('../views/xitong/dazhi.vue')
              },
              {
                path:'xinchengqu',
                name:'xinchengqu',
                component: () => import('../views/xitong/xinchengqu.vue')
              },
              {
                path:'linwei',
                name:'linwei',
                component: () => import('../views/xitong/linwei.vue')
              },
            ]
          },
          {
            path: '/',
            name: 'quanxian',
            component: () => import('../views/xitong/quanxian.vue')
          },
          {
            path: 'yonghu',
            name: 'yonghu',
            component: () => import('../views/xitong/yonghu.vue'),
            children: [
              {
                path:'/home/settion/yonghu/shanxi',
                name:'shanxi',
                component: () => import('../views/xitong/shanxi.vue')
              },
              {
                path:'/home/settion/yonghu/han',
                name:'han',
                component: () => import('../views/xitong/han.vue')
              },
              {
                path:'/home/settion/yonghu/xia',
                name:'xia',
                component: () => import('../views/xitong/xia.vue')
              },
              {
                path:'/home/settion/yonghu/wein',
                name:'wein',
                component: () => import('../views/xitong/wein.vue')
              },              {
                path:'/home/settion/yonghu/hant',
                name:'hant',
                component: () => import('../views/xitong/hant.vue')
              },
              {
                path:'/home/settion/yonghu/nanz',
                name:'nanz',
                component: () => import('../views/xitong/nanz.vue')
              },
              {
                path:'/home/settion/yonghu/beil',
                name:'beil',
                component: () => import('../views/xitong/beil.vue')
              },
              {
                path:'/home/settion/yonghu/daz',
                name:'daz',
                component: () => import('../views/xitong/daz.vue')
              },
              {
                path:'/home/settion/yonghu/xincheng',
                name:'xincheng',
                component: () => import('../views/xitong/xincheng.vue')
              },
              {
                path:'/home/settion/yonghu/linw',
                name:'linw',
                component: () => import('../views/xitong/linw.vue')
              },
            ]
          },
          {
            path: 'zuzhi',
            name: 'zuzhi',
            component: () => import('../views/xitong/zuzhi.vue')
          }
        ]
      },
    ],
  },
];


const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes,
});


router.beforeEach((to, from, next) => {
  if (to.path === '/') return next()
  let sureToken = sessionStorage.getItem('登录信息')
  if (!sureToken) {
    return next('/')
  }
  next()
})

export default router;
